#include<vector>
#include<iostream>
using std::vector;


class Solution {
public:
    int majorityElement(vector<int>& nums) {
        if (nums.empty()) return 0;
        int major = nums[0];
        int count = 1;
        for (int i = 1; i < nums.size(); i++) {
            if (major == nums[i]) count ++;
            else if (count > 1) count --;
            else if (count <= 1) {
                major = nums[i];
                count = 1;
            }
        }
        return major;
    }
};


int main() {
    int tmp;
    vector<int> nums;
    while (std::cin >> tmp) {
        nums.push_back(tmp);
    }
    for (auto n: nums) {
        std::cout << n << " ";
    }
    std::cout << "\n";
    int result = Solution().majorityElement(nums);
    std::cout << "major: " << result << "\n";
    return 0;

}


